﻿using Architecture.Api.Application.Commands.DeepProcessingCommand;
using Architecture.Api.Application.Commands.SlaughterCommand;
using Architecture.Domain.Services.Interface;
using Architecture.Domain.TraceabilityManage;
using Architecture.Repository.Interface;
using AutoMapper;
using MediatR;

namespace Architecture.Api.Application.CommandHandlers.DeepProcessingHandler
{
    public class DeepProcessingCreateCommandHandler : IRequestHandler<DeepProcessingCreateCommand, int>
    {
        private readonly IDeepProcessingService _deepProcessingService;
        private readonly IMapper _mapper;

        public DeepProcessingCreateCommandHandler(
            IDeepProcessingService deepProcessingService,
            IMapper mapper)
        {
            _deepProcessingService = deepProcessingService;
            _mapper = mapper;
        }

        public async Task<int> Handle(DeepProcessingCreateCommand request, CancellationToken cancellationToken)
        {
            DeepProcessing deep = _mapper.Map<DeepProcessing>(request);
            return await _deepProcessingService.AddDeepProcessing(deep);
        }
    }
}